package com.vn.ld.user.facade;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.vn.ld.api.user.dto.CustomerDTO;
import com.vn.ld.api.user.service.RSUserService;
import com.vn.ld.api.utils.ObjectConverter;
import com.vn.ld.btc.dao.entity.Customer;
import com.vn.ld.user.service.UserService;

public class UserServiceFacade implements RSUserService {
	@Autowired
	private UserService userService;

	@Autowired
	private ObjectConverter objectConverter;

	@Override
	public List<CustomerDTO> getAllCustomers() {
		List<Customer> customersList = this.userService.getAllCustomer();
		List<CustomerDTO> result = new ArrayList<CustomerDTO>();
		CustomerDTO dto = null;
		for (Customer customer : customersList) {
			dto = (CustomerDTO) this.objectConverter.convert(customer, new CustomerDTO());
			if (dto != null) {
				result.add(dto);
			}
		}
		return result;
	}

}
